

# 491.递增子序列

def main(nums):
    result = []
    temp = []
    def backtrack(startIndex):
        if len(temp) >= 2 and temp not in result:
            result.append(temp[:])
        for i in range(startIndex, len(nums)):
            if temp == []:
                temp.append(nums[i])
            else:
                if nums[i]>=temp[-1]:
                    temp.append(nums[i])
            backtrack(i + 1)
            if temp != []:
                temp.pop()
    backtrack(0)
    return result

if __name__ == "__main__":
    nums = [1,2,3,1]
    result = main(nums)
    print(result)